package gui.menu;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;

import tiles.IsometricSprite;
import gui.menu.addons.ToolMenuItem;

public class ToolMenuTitleBar implements ToolMenuItem {

	private final int HEIGHT = 20;
	private int width;
	private String title = null;

	@Override
	public void draw(Graphics g, int x, int y) {
		if (title != null) {

			int max_length = 20;
			int adjustment = 5;

			String tmp = title.substring(0, Math
					.min(title.length(), max_length));
			tmp = (tmp.length() < title.length() ? tmp + "..." : tmp);

			g.setColor(Color.black);
			g.drawRect(x, y, width, HEIGHT);
			g.setColor(Color.red);
			g.fillRect(x + 1, y + 1, width - 1, HEIGHT - 1);
			g.setColor(Color.white);
			g.drawString(tmp, x + adjustment, y + HEIGHT - adjustment);
		}
	}

	@Override
	public boolean inBounds(Point p) {
		return false;
	}

	@Override
	public void mouseAction(MouseEvent evt) {}

	@Override
	public void setTile(IsometricSprite iso) {
		title = iso.toString();
	}

	@Override
	public void setWidth(int width) {
		this.width = width;
	}

	@Override
	public int getHeight() {
		return HEIGHT;
	}

	@Override
	public void mainMenuClosed() {}

	@Override
	public void mouseWheelAction(MouseWheelEvent evt) {}

}
